#define _CRT_SECURE_NO_WARNINGS 1
#include"SeqList.h"

void InitList(SeqList* L)
{
	assert(L);
	L->length = 0;
}

void PushBack(SeqList* L, DataType x)
{
	assert(L);
	assert(L->length != ListSize);
	L->list[L->length] = x;
	L->length++;
}
void PrintList(SeqList* L)
{
	assert(L);
	for (int i = 0; i < L->length; i++)
	{
		printf("%d ", L->list[i]);
	}
	printf("\n");
}

void PrintLength(SeqList* L)
{
	assert(L);
	printf("%d\n", L->length);
}

void GetElem(SeqList* L, int i)
{
	assert(L);
	assert(i > 0 && i <= L->length);
	printf("%d\n", L->list[i - 1]);
}

void InsertList(SeqList* L, int i, DataType x)
{
	assert(L);
	assert(i > 0 && i <= L->length);
	assert(L->length != ListSize);
	for (int j = L->length - 1; j >= i - 1; j--)
	{
		L->list[j + 1] = L->list[j];
	}
	L->list[i - 1] = x;
	L->length++;
}

void DeleteList(SeqList* L, int i)
{
	assert(L);
	assert(i > 0 && i <= L->length);
	for (int j = i; j <= L->length - 1; j++)
	{
		L->list[j - 1] = L->list[j];
	}
	L->length--;
}

void ClearList(SeqList* L)
{
	L->length = 0;
}